/*
 * @FilePath: \flutter_ducafecat_news_getx\lib\pages\main\widgets\like.dart
 * @Date: 2022-07-15 17:15:31
 * @LastEditTime: 2022-07-18 13:27:28
 * @Description: 
 */
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_ducafecat_news_getx/common/entities/card.dart';
import 'package:flutter_ducafecat_news_getx/common/values/colors.dart';
import 'package:flutter_ducafecat_news_getx/common/widgets/components.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import '../index.dart';

var logger = Logger();

///后部分平滑。定义本地json[]数据,后期网络获取。
const likedata = [
  {
    "bg": "assets/images/feature-1.png",
    "lt": true,
    "rt": "122.2亿",
    "lbo": '华语',
    "lbt": '私人定制',
    "bottom": "一听就想单曲循环的粤语歌曲"
  },
  {
    "bg": "assets/images/feature-2.png",
    "lt": true,
    "rt": "192万",
    "lbo": '时光',
    "lbt": '雷达',
    "bottom": "美到窒息的小提琴曲，每一首都不会错过"
  },
  {
    "bg": "assets/images/feature-3.png",
    "lt": true,
    "rt": "371万",
    "lbo": '乐迷',
    "lbt": '雷达',
    "bottom": "华语今典 | 怀旧音乐时光机"
  },
  {
    "bg": "assets/images/eg_1.jpg",
    "lt": true,
    "rt": "79万",
    "lbo": '宝藏',
    "lbt": '雷达',
    "bottom": "网易云音乐10万+评论合集"
  },
  {
    "bg": "assets/images/eg_2.png",
    "lt": true,
    "rt": "51万",
    "lbo": '新歌',
    "lbt": '雷达',
    "bottom": "今天从灰色轨迹听起|私人雷达"
  },
  {
    "bg": "assets/images/eg_3.png",
    "lt": true,
    "rt": "3556万",
    "lbo": 'Bass',
    "lbt": 'Party',
    "bottom": "阿尔法脑波音乐[激发右脑潜能]"
  }
];
//通过json为实体类
final likeList =
    likedata.map<CardMusic>((item) => CardMusic.fromJson(item)).toList();
//后部分平滑移动
final List<Widget> likes = likeList
    .map((card) => musicCardMy(
        bg: card.bg,
        lt: card.lt,
        rt: card.rt,
        lbo: card.lbo,
        lbt: card.lbt,
        bottom: card.bottom))
    .toList();

class Like extends GetView<MainController> {
  @override
  Widget build(BuildContext context) {
    // logger.d(context);
    return Container(
        height: 230.h,
        width: 375.w,
        padding: EdgeInsets.fromLTRB(10.w, 20.h, 10.w, 15.h),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(15.h)),
          color: AppColors.cardbg,
        ),
        child: Column(children: [
          Container(
            height: 40.h,
            width: 355.w,
            child: Row(
              children: [
                SizedBox(
                  height: 40.h,
                  width: 218.w,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text('猜你喜欢',
                          style: TextStyle(
                              fontSize: 10.sp, color: AppColors.like)),
                      Text('烟霞生水云的雷达歌单',
                          style: TextStyle(
                              fontSize: 18.sp, fontWeight: FontWeight.bold))
                    ],
                  ),
                ),
                Container(
                  height: 25.h,
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(15.w)),
                      border: Border.all(
                          width: 0.5,
                          color: Colors.transparent.withOpacity(0.3)),
                      color: AppColors.tagNum),
                  child: TextButton(
                    style: ButtonStyle(
                      visualDensity: VisualDensity.compact,
                      foregroundColor: MaterialStateProperty.all(
                          AppColors.primaryBackground),
                    ),
                    onPressed: () {},
                    child: Row(
                      children: [
                        Icon(
                          Icons.add,
                          size: 12.sp,
                        ),
                        Text('添加'),
                      ],
                    ),
                  ),
                ),
                SizedBox(
                  width: 10.w,
                ),
                Container(
                  height: 25.h,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(15.w)),
                    border: Border.all(
                        width: 0.5, color: Colors.transparent.withOpacity(0.3)),
                  ),
                  child: TextButton(
                    style: ButtonStyle(
                      visualDensity: VisualDensity.compact,
                      foregroundColor: MaterialStateProperty.all(Colors.black),
                    ),
                    onPressed: () {},
                    child: Row(
                      children: [
                        Text('不感兴趣'),
                      ],
                    ),
                  ),
                )
              ],
            ),
          ),
          SizedBox(
            height: 10.h,
          ),
          SizedBox(
            height: 140.h,
            width: 375.w,
            child: ListView(
              padding: EdgeInsets.symmetric(horizontal: 10.w),
              // reverse: true,
              scrollDirection: Axis.horizontal,
              children: likes,
            ),
          )
        ]));
  }
}
